snapcast: add package snapserver and snapclient
authorSzabolcs Hubai <[email protected]>
Wed, 17 Apr 2024 22:23:26 +0000 (00:23 +0200)
committerTianling Shen <[email protected]>
Tue, 9 Sep 2025 04:57:14 +0000 (12:57 +0800)
Snapcast [1] is a multiroom client-server audio player, where all
clients are time synchronized with the server to play perfectly synced
audio.

It's not a standalone player, but an extension that turns your existing
audio player into a Sonos-like multiroom solution.
Audio is captured by the server and routed to the connected clients.
Several players can feed audio to the server in parallel and clients can
be grouped to play the same audio stream.
One of the most generic ways to use Snapcast is in conjunction with the
music player daemon (MPD) [2] or Mopidy [3].

The inclusion starts with version 0.28.0 because of OpenSSL dependency
issues of version 0.29.0. Newer versions (e.g. 0.32.3, see [4])
with optional OpenSSL support, will be incorporated with flavours,
like "-mini" and "-full" in the upcoming PRs.
More about this topic please check the inclusion PR at [5]!

[1]: https://github.com/badaix/snapcast
[2]: http://www.musicpd.org/
[3]: https://www.mopidy.com/
[4]: https://github.com/badaix/snapcast/blob/develop/changelog.md
[5]: https://github.com/openwrt/packages/pull/23956#discussion_r2330463363

Fixes: #23924
Suggested-by: Tianling Shen <[email protected]>
Suggested-by: George Sapkin <[email protected]>
Signed-off-by: Szabolcs Hubai <[email protected]>
sound/snapcast/Makefile
sound/snapcast/files/snapclient.conf [new file with mode: 0644]
sound/snapcast/files/snapclient.init
sound/snapcast/files/snapserver.conf [new file with mode: 0644]
sound/snapcast/files/snapserver.init
sound/snapcast/test.sh [new file with mode: 0755]

index a7c229176563bbf1950932ccc9f31d57b2e7e032..df23e780ab7e346c1a6c1025c26277e62a9806bf 100644 (file)
@@ -1,22 +1,20 @@
-#
-# Copyright (C) 2015 OpenWrt.org
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
+# SPDX-License-Identifier: GPL-2.0-or-later
 
 include $(TOPDIR)/rules.mk
 
-PKG_NAME := snapcast
-PKG_VERSION := 0.27.0
-PKG_RELEASE := $(PKG_SOURCE_VERSION)
-PKG_USE_MIPS16 := 0
+PKG_NAME:=snapcast
+PKG_VERSION:=0.28.0
+PKG_RELEASE:=1
 
-# PKG_MIRROR_HASH=skip
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL:=https://github.com/badaix/snapcast.git
-PKG_SOURCE_VERSION:=v0.27.0
-PKG_BUILD_DIR:=$(BUILD_DIR)/snapcast-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=v$(PKG_VERSION)
+PKG_MIRROR_HASH=288325fc8b134502adb522711c18210794734675684cf5d8eba8a0a82778f6c9
+
+PKG_MAINTAINER:=Szabolcs Hubai <[email protected]>, David Andreoletti <[email protected]>
+PKG_LICENSE:=GPL-3.0-or-later
+PKG_LICENSE_FILES:=LICENSE
+PKG_CPE_ID:=cpe:/a:badaix:snapcast
 
 include $(INCLUDE_DIR)/package.mk
 include $(INCLUDE_DIR)/cmake.mk
@@ -24,73 +22,58 @@ include $(INCLUDE_DIR)/cmake.mk
 CMAKE_OPTIONS += -DBUILD_TESTS=OFF
 
 define Package/snapcast/Default
-       SECTION := sound
-       CATEGORY := Sound
-       TITLE := Synchronous multiroom audio player
-       DEPENDS := +AUDIO_SUPPORT:alsa-lib +libstdcpp +libavahi-client +libatomic +libogg +libflac +libopus +boost +libsoxr
-       URL := https://github.com/badaix/snapcast
+  SECTION:=sound
+  CATEGORY:=Sound
+  TITLE:=Synchronous multiroom audio player
+  DEPENDS:=+AUDIO_SUPPORT:alsa-lib +libavahi-client +libatomic +libogg +libflac +libopus +boost +libsoxr
+  URL:=https://github.com/badaix/snapcast
 endef
 
-define Package/snapcast/description/Default
-       Synchronous audio player
-endef
+define Package/snapcast/Default/description
+  Synchronous audio player - Snapcast
 
-define Package/snapcast
-       $(call Package/snapcast/Default)
-       TITLE += packages
-endef
+  Snapcast is a multi-room client-server audio player,
+  where all clients are time synchronized with the server
+  to play perfectly synced audio.
+  It's not a standalone player, but an extension that turns
+  your existing audio player into a Sonos-like multiroom solution.
+  Audio is captured by the server and routed to the connected clients.
+  Several players can feed audio to the server in parallel
+  and clients can be grouped to play the same audio stream.
+  One of the most generic ways to use Snapcast is in conjunction
+  with the Music Player Daemon (MPD) or Mopidy.
 
-define Package/snapcast/description
-       $(call Package/snapcast/description/Default)
-       Snapcast is a multi-room client-server audio player, 
-       where all clients are time synchronized with the server 
-       to play perfectly synced audio
 endef
 
 define Package/snapserver
-       $(call Package/snapcast/Default)
-       TITLE += Snapserver
-       DEPENDS += +AUDIO_SUPPORT:alsa-lib +libvorbis +libsoxr
-       HIDDEN := 1
+  $(call Package/snapcast/Default)
+  TITLE+= (server)
+  DEPENDS+=+libvorbis
 endef
 
 define Package/snapclient
-       $(call Package/snapcast/Default)
-       TILE += Snapclient
-       DEPENDS += +libvorbisidec +libsoxr
-       HIDDEN := 1
+  $(call Package/snapcast/Default)
+  TITLE+= (client)
+  DEPENDS+=+libvorbisidec
 endef
 
 define Package/snapserver/description
-       $(call Package/snapcast/description/Default)
-       Snapcast server
+  $(call Package/snapcast/Default/description)
+  This package contains the Snapcast server.
 endef
 
 define Package/snapclient/description
-       $(call Package/snapcast/description/Default)
-       Snapcast client
+  $(call Package/snapcast/Default/description)
+  This package contains the Snapcast client.
 endef
 
-define Package/snapcast/config
-       menu "Select Snapcast Options"
-               depends on PACKAGE_snapcast
-               comment "Choose server or client"
-               config PACKAGE_snapserver
-                       prompt "Snapserver"
-                       help
-                               Snapcast server
-                       default n
-
-               config PACKAGE_snapclient
-                       prompt "Snapclient"
-                       help
-                               Snapcast client
-                       default y
-       endmenu
+define Package/snapserver/conffiles
+/etc/config/snapserver
+/etc/snapserver.conf
 endef
 
-define Package/snapcast/Default/install
-       true
+define Package/snapclient/conffiles
+/etc/config/snapclient
 endef
 
 define Package/snapserver/install
@@ -98,8 +81,6 @@ define Package/snapserver/install
        $(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/snapserver $(1)/usr/bin/
        $(INSTALL_DIR) $(1)/etc/init.d
        $(INSTALL_BIN) ./files/snapserver.init $(1)/etc/init.d/snapserver
-       $(INSTALL_DIR) $(1)/etc/default
-       $(INSTALL_BIN) $(CURDIR)/../../debian/snapserver.default $(1)/etc/default/snapserver
        $(INSTALL_BIN) $(PKG_BUILD_DIR)/server/etc/snapserver.conf $(1)/etc/snapserver.conf
 endef
 
@@ -108,10 +89,7 @@ define Package/snapclient/install
        $(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/snapclient $(1)/usr/bin/
        $(INSTALL_DIR) $(1)/etc/init.d
        $(INSTALL_BIN) ./files/snapclient.init $(1)/etc/init.d/snapclient
-       $(INSTALL_DIR) $(1)/etc/default
-       $(INSTALL_BIN) $(CURDIR)/../../debian/snapclient.default $(1)/etc/default/snapclient
 endef
 
 $(eval $(call BuildPackage,snapserver))
 $(eval $(call BuildPackage,snapclient))
-$(eval $(call BuildPackage,snapcast))
diff --git a/sound/snapcast/files/snapclient.conf b/sound/snapcast/files/snapclient.conf
new file mode 100644 (file)
index 0000000..051890a
--- /dev/null
@@ -0,0 +1,4 @@
+config snapclient 'config'
+       option enabled '0'
+       option log_sink 'system'
+       option opts ''
index 9bace4b08421ff2752a69ec34aec9a7c59f4b573..49e95dc4150faa8a730e201fb9c603e8a55f8e65 100755 (executable)
@@ -1,5 +1,6 @@
 #!/bin/sh /etc/rc.common
 # Author: Johannes Pohl <[email protected]>
+# Co-Author: Szabolcs Hubai <[email protected]>
 START=90
 
 USE_PROCD=1
@@ -7,21 +8,22 @@ USE_PROCD=1
 NAME=snapclient
 PROG=/usr/bin/$NAME
 PID_FILE=/var/run/$NAME.pid
-CONFIG_FILE=/etc/default/$NAME
-
 
 start_service()
 {
-       local autostart opts
+       config_load "$NAME"
 
-       autostart=$(grep ^START_SNAPCLIENT $CONFIG_FILE |cut -d= -f2)
-       [ "$autostart" != "true" ] && logger -t $NAME "Not starting due to START_SNAPCLIENT" && exit 0
+       local enabled
+       config_get_bool enabled "config" enabled 0
+       [ "$enabled" -ne "1" ] && logger -t $NAME "Disabled in /etc/config/$NAME" && return 1
 
-       opts=$(grep ^SNAPCLIENT_OPTS $CONFIG_FILE |cut -d "\"" -f2)
-       opts="--logsink system $opts"
+       local log_sink opts
+       config_get log_sink "config" log_sink system
+       config_get opts "config" opts ""
 
        procd_open_instance
        procd_set_param command $PROG
+       procd_append_param command --logsink $log_sink
        procd_append_param command $opts
        procd_set_param pidfile $PID_FILE
        procd_set_param respawn # use the defaults for respawing crashed process
diff --git a/sound/snapcast/files/snapserver.conf b/sound/snapcast/files/snapserver.conf
new file mode 100644 (file)
index 0000000..a341c48
--- /dev/null
@@ -0,0 +1,4 @@
+config snapserver 'config'
+       option enabled '0'
+       option log_sink 'system'
+       option opts ''
index 0747fe95c9253551a99431562099f72d6819c8b0..7aae17a200c6a5765c7822faa9ef127076a404e2 100755 (executable)
@@ -1,5 +1,6 @@
 #!/bin/sh /etc/rc.common
 # Author: Johannes Pohl <[email protected]>
+# Co-Author: Szabolcs Hubai <[email protected]>
 START=90
 
 USE_PROCD=1
@@ -7,21 +8,22 @@ USE_PROCD=1
 NAME=snapserver
 PROG=/usr/bin/$NAME
 PID_FILE=/var/run/$NAME.pid
-CONFIG_FILE=/etc/default/$NAME
-
 
 start_service()
 {
-       local autostart opts
+       config_load "$NAME"
 
-       autostart=$(grep ^START_SNAPSERVER $CONFIG_FILE |cut -d= -f2)
-       [ "$autostart" != "true" ] && logger -t $NAME "Not starting due to START_SNAPSERVER" && exit 0
+       local enabled
+       config_get_bool enabled "config" enabled 0
+       [ "$enabled" -ne "1" ] && logger -t $NAME "Disabled in /etc/config/$NAME" && return 1
 
-       opts=$(grep ^SNAPSERVER_OPTS $CONFIG_FILE |cut -d "\"" -f2)
-       opts="--logging.sink system $opts"
+       local log_sink opts
+       config_get log_sink "config" log_sink system
+       config_get opts "config" opts ""
 
        procd_open_instance
        procd_set_param command $PROG
+       procd_append_param command --logging.sink $log_sink
        procd_append_param command $opts
        procd_set_param pidfile $PID_FILE
        procd_set_param respawn # use the defaults for respawing crashed process
diff --git a/sound/snapcast/test.sh b/sound/snapcast/test.sh
new file mode 100755 (executable)
index 0000000..fb410e0
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+"$1" --version | grep -F "$PKG_VERSION"